package com.orange.modules.dao;

import java.sql.SQLException;
import java.util.List;

import javax.annotation.Resource;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Repository;

import com.orange.dbhelp.DbHelper;
import com.orange.modules.entity.AuthFileCatalogMap;

@Repository
public class AuthFileCatalogMapRepository {
	
	@Resource(name = "dbHelper")
	private DbHelper dbHelper;
	
	/**
	 * 根据目录ID查找该目录下的所有文件
	 * @param catalogId
	 * @return
	 * @throws SQLException
	 */
	public List<AuthFileCatalogMap> queryFileByCatalogId(String catalogId) throws SQLException{
		String sql = "SELECT t.p_id as pid,t.catalog_id as catalogId,t.f_path as path,t.f_name as fileName,t.s_creattime as createtime "
				+ "FROM t_auth_file_catalog_map t WHERE 1=1 ";
		if(catalogId!=null && StringUtils.isNotBlank(catalogId))
			sql+=" AND t.catalog_id ='"+catalogId+"'";
		List<AuthFileCatalogMap> list  = dbHelper.getBeanList(sql, AuthFileCatalogMap.class, null);
		return list;
	}
	
}
